﻿/**
 * TestCaseItem.cs
 *
 * Copyright (C) 2008,  iron9light
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

using System;
using System.Collections;
//using System.Collections.Generic;
using NUnit.Framework.Constraints;

namespace NUnitExtension.DataDriven
{
    /// <summary>
    /// The <c>TestCaseItem</c> class represents a set of arguments
    /// and a set of constraints info to be used for a parameterized
    /// test case.
    /// </summary>
    public class TestCaseItem
    {
        private readonly object[] m_Arguments;
        //private IList<Constraint> m_Constraints;
        private IList m_Constraints;
        //private string m_Description;
        //private string m_TestName;

        /// <summary>
        /// Initializes a new instance of the <c>TestCaseItem</c> class.
        /// </summary>
        public TestCaseItem()
        {
            m_Arguments = null;
        }

        /// <summary>
        /// Initializes a new instance of the <c>TestCaseItem</c> class with arguments.
        /// </summary>
        public TestCaseItem(params object[] arguments)
        {
            m_Arguments = arguments;
        }

        /// <summary>
        /// Get arguments.
        /// </summary>
        public object[] Arguments
        {
            get
            {
                return m_Arguments;
            }
        }

        /// <summary>
        /// Add a constraint.
        /// </summary>
        /// <param name="constraint">The constraint.</param>
        /// <returns>This <c>TestCaseItem</c>.</returns>
        public TestCaseItem That(Constraint constraint)
        {
            if(constraint == null)
            {
                throw new ArgumentNullException("constraint");
            }

            if (m_Constraints == null)
                //m_Constraints = new List<Constraint>();
                m_Constraints = new ArrayList();

            m_Constraints.Add(constraint);
            return this;
        }

        /// <summary>
        /// Get constraints list.
        /// </summary>
        //public IList<Constraint> Constraints
        public IList Constraints
        {
            get
            {
                return m_Constraints;
            }
        }

        ///// <summary>
        ///// Gets or sets the description.
        ///// </summary>
        ///// <value>The description.</value>
        //public string Description
        //{
        //    get { return m_Description; }
        //    set { m_Description = value; }
        //}

        ///// <summary>
        ///// Gets or sets the name of the test.
        ///// </summary>
        ///// <value>The name of the test.</value>
        //public string TestName
        //{
        //    get { return m_TestName; }
        //    set { m_TestName = value; }
        //}
    }
}
